<template>
    <transition
      name="custom-classer-transition"
      enter-active-class="animated fadeInDown"
      leave-active-class="animated fadeOutUp"
    >
      <div class="modal-ctrl-body" v-show="updateClassObj.isShow"
      >
        <div class="modal-ctrl-main odd-row-ctrl">
          <div class="modal-title">
            <p>修改重点人类型</p>
          </div>
          <div class="modal-ctrl-content">
            <div class="modal-row" >
              <div class="modal-form-key f-l indispensable">
                类型名称：
              </div>
              <input type="text" v-model="ModalData.typename" class="modal-text f-l">
            </div>
            <!--              <div class="modal-row" >
                            <div class="modal-form-key f-l indispensable">
                              类型键值：
                            </div>
                            <input type="text" v-model="ModalData.typekey" class="modal-text f-l">
                          </div>

                          <div class="modal-row" >
                            <div class="modal-form-key f-l indispensable">
                              类型：
                            </div>
                            &lt;!&ndash;<input type="number" v-model.number="ModalData.type" class="modal-text f-l input-number"  >&ndash;&gt;
                            <select name="" v-model.number="ModalData.type">
                              <option value="0">0</option>
                              <option value="1">1</option>
                            </select>
                          </div>-->

          </div>
          <div class="btns text-r">
            <button type="button" class="btn btn-default"  @click="close">取消</button>
            <button type="button" class="btn btn-info" @click="subBtn">确定</button>
          </div>
        </div>
      </div>
    </transition>
</template>

<script>
  export default {
    name: "updateClassModel",
    props:["updateClassObj"],
    data(){
      return {
        ModalData: {
          typename: '',       // 类型名称
          typekey: '',        // 类型键值
          isDelete: 0,        //  0 未删除 1 已删除
          hierarchy: '',        //
          type: 0,           // 重点人类型的类型
          createStationId: 0,           // 创建人的部门ID
          parentid: '',           // 上级部门ID
        },
        id: ''
      }
    },
    methods: {
      //关闭弹窗
      close(){
        this.$emit("updateClassClose");
        this.clearData(); //关闭弹窗清除数据
      },
      //提交
      subBtn(){
        // 父节点id为点击部门的id
        this.ModalData.typename = this.JPtool.subBlank(this.ModalData.typename);
        if(this.verifyForm.isNull(this.ModalData.typename)){
          this.s_alert('请输重点人类型名称！');
          // alert('请输重点人类型名称！');
          return false;
        }
        let url = this.ControlObject+'/BS/ImportPersonType/'+this.id;
        this.$axios({
          url: url,
          data: this.ModalData,
          method: 'put'
        })
          .then(res => {
            this.s_alert('修改成功');
            // alert('修改成功');
            this.clearData();
            this.close()
          })
          .catch(err => {
            this.s_alert('修改失败'+err.response.data.errorMsg);
            // alert('修改失败'+err.response.data.errorMsg);
          })
      },
      clearData(){
        this.ModalData = {
          typename: '',       // 类型名称 ,
          typekey: '',        // 类型键值,
          isDelete: 0,        //  0 未删除 1 已删除
          hierarchy: '',        //  0 未删除 1 已删除
          type: 0,           // 重点人类型的类型 ,
          createStationId: '',           // 创建人的部门ID
          parentid: '',           // 上级部门ID
        }
        this.id = '';
      }
    }, // end methods
    watch: {
      updateClassObj: {
        handler (val) {
          //console.log(val);
          this.ModalData.typename = val.typename;
          this.ModalData.typekey = val.typekey;
          this.ModalData.isDelete = val.isDelete;
          this.ModalData.hierarchy = val.hierarchy;
          this.ModalData.type = val.type;
          this.ModalData.createStationId = val.createStationId;
          this.ModalData.parentid = val.parentid;

          this.id = val.id;
        },
        deep: true
      }
    }
  }
</script>

<style scoped>
  .input-number {
    width: 60%;
  }
  .fadeInDown,.fadeOutUp{
    animation-duration: .500s;
  }
</style>
